package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Account   string `gorm:"type:varchar(30);not null;comment: 账号"`
	Password  string `gorm:"type:char(32);not null;comment: 密码"`
	HeadImage string `gorm:"type:varchar(500);not null;comment: 头像"`
	Name      string `gorm:"type:varchar(30);not null;comment: 昵称"`
}

func (u *User) FindUser(db *gorm.DB, account string) error {
	return db.Debug().Where("account = ?", account).Find(u).Error
}

func (u *User) UserShow(db *gorm.DB, id int64) error {
	return db.Model(&User{}).Where("id = ?", id).Find(&u).Error
}

func (u *User) FindUsers(db *gorm.DB, id int64) interface{} {
	return db.Debug().Where("id = ?", id).Find(u).Error
}
